﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ras2ClassLib;

namespace Ras2Form
{
    public partial class HitListAddDlg : Form
    {
        private UISong m_song = null;

        public UISong Song
        {
            get { return m_song; }
            set { m_song = value; }
        }

        public HitListAddDlg()
        {
            InitializeComponent();
        }

        private void OnLoad(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                SongController controller = new SongController();
                foreach (UISong s in controller.GetAllSongs())
                {
                    m_lvHitList.Items.Add(CreateListViewItem(s));
                }
            }
        }

        private ListViewItem CreateListViewItem(UISong row)
        {
            ListViewItem item = new ListViewItem(row.Name);

            item.SubItems.Add(row.PerformerName);

            item.ImageIndex = 0;
            item.Tag = row;

            return item;
        }

        private void OnSelIndexChanged(object sender, EventArgs e)
        {
            if (m_lvHitList.SelectedItems.Count == 1)
            {
                ListViewItem listViewItem = m_lvHitList.SelectedItems[0];
                m_song = (UISong)listViewItem.Tag;
            }
        }

        private void OnDoubleClick(object sender, MouseEventArgs e)
        {
            m_btnOK.PerformClick();
        }

    }
}
